﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace eeenno.ReaderEngine.Utilities
{
    public class ThreadFactory
    {
        public static Thread GetThread(string taskName, ThreadStart taskDelegate)
        {
            Thread ret_val = new Thread(taskDelegate);
            ret_val.Name = taskName;
            ret_val.Priority = ThreadPriority.Normal;
            ret_val.IsBackground = false;
            return ret_val;
        }

        public static Thread GetUIThread(string taskName, ThreadStart taskDelegate)
        {
            Thread ret_val = new Thread(taskDelegate);
            ret_val.Name = taskName;
            ret_val.Priority = ThreadPriority.AboveNormal;
            ret_val.IsBackground = false;
            return ret_val;
        }

        public static void DoWork(WaitCallback work)
        {
            ThreadPool.QueueUserWorkItem(work);
        }

        public static void DoWork(WaitCallback work, object stateInfo)
        {
            ThreadPool.QueueUserWorkItem(work, stateInfo);
        }
    }
}
